//
//  YFCustomTemplateCell.m
//  SquashSpark
//
//  Created by Coollang on 2017/11/29.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "YFCustomTemplateCell.h"

@interface YFCustomTemplateCell()

@property (weak, nonatomic) IBOutlet UILabel *typeNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *emplateTitlelabel;
@property (weak, nonatomic) IBOutlet UILabel *creatTimeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *leftLineImageView;
@property (weak, nonatomic) IBOutlet UIImageView *accessoryRightImageView;

@property (nonatomic, strong) YFThreeDTemplate *threeDtemplate;
@property (nonatomic, assign) BOOL isEditing;

@end

@implementation YFCustomTemplateCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (void)configuerCellWithModel:(YFThreeDTemplate *)threeDtemplate isEditing:(BOOL)isEditing {
    self.threeDtemplate = threeDtemplate;
    self.isEditing = isEditing;
    self.creatTimeLabel.text = [NSDate timeWithTimeIntervalString:threeDtemplate.creatTimestamp formatter:@"yyyy.MM.dd"];
    self.emplateTitlelabel.text = threeDtemplate.name;
//    self.typeNameLabel.text = threeDtemplate.threeDItem.typeString;
    self.typeNameLabel.text = [YFThreeDTemplate templateWithHandType:threeDtemplate.handType selectActionType:threeDtemplate.selectActionType];
    
    if (isEditing) {
//        self.leftLineImageView.hidden = !threeDtemplate.isDeletSelect;
        self.leftLineImageView.hidden = YES;
        self.accessoryRightImageView.image = threeDtemplate.isDeletSelect ? [UIImage imageNamed:@"login_select_dot"]:[UIImage imageNamed:@"login_unselect_dot"];
    }else {
        self.accessoryRightImageView.image = [UIImage imageNamed:@"user_icon_arrow"];
        self.leftLineImageView.hidden = ![threeDtemplate.identification isEqualToString:[User getLastUser].currentSelectTemplate.identification];
    }
}

- (void)dealloc {
   // [self.threeDtemplate removeObserver:self forKeyPath:@"isDeletSelect"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
    
}

@end
